package com.share.user.factory;

import com.share.common.core.domain.R;
import com.share.user.api.RemoteUserService;
import com.share.user.domain.UpdateUserLogin;
import com.share.user.domain.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @version 1.0
 * @author: CY_Guo
 * @date: 2025/5/12 15:41
 * @Descript TODO 请概括该类
 */
public class RemoteUserInfoFallbackFactory implements FallbackFactory<RemoteUserService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserInfoFallbackFactory.class);


    @Override
    public RemoteUserService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteUserService() {

            @Override
            public R<UserInfo> wxLogin(String code, String source) {
                return R.fail("微信登录失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> updateUserLogin(UpdateUserLogin updateUserLogin) {
                return R.fail("更新用户登录失败:" + throwable.getMessage());
            }

            @Override
            public R<UserInfo> getInfo(Long id) {
                return  R.fail("获取用户信息失败:" + throwable.getMessage());
            }

            @Override
            public R getUserCount() {
                return null;
            }
        };
    }
}
